package com.yijiu.response;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.yijiu.network.Response;
import com.yijiu.resource.InvestRecord;

public class InvestRecordResponse extends Response {

	public List<InvestRecord> investRecordList;
	
	public String investedTotalAmount;

	@Override
	protected void jsonToObject() {
		investRecordList = new ArrayList<InvestRecord>();
		try {
			JSONObject data = reposonJson.getJSONObject("result");
			investedTotalAmount = data.getString("investedTotalAmount");
			JSONArray array = data.getJSONArray("infos");
			int size = array.length();
			for (int i = 0; i < size; i++) {
				JSONObject object = array.getJSONObject(i);
				InvestRecord investRecord = new InvestRecord();
				investRecord.tradeId = object.optLong("tradeId");
				investRecord.loanerUserName = object.optString("loanerUserName");
				investRecord.investflowCode = object.optString("investflowCode");
				investRecord.amount = object.optString("amount");
				investRecord.date = object.optString("date");
				investRecord.detailId = object.optLong("detailId");
				investRecord.status = object.optString("status");
				investRecordList.add(investRecord);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

}